Skip to content

Handle model provider timeouts and errors#4521

Open
KyleAMathews wants to merge 3 commits into
mainfrom
fix/4520-model-provider-errors
Open

Handle model provider timeouts and errors#4521
KyleAMathews wants to merge 3 commits into
mainfrom
fix/4520-model-provider-errors

Conversation

@KyleAMathews

Copy link
Copy Markdown
Contributor

Fixes #4520.

Summary

  • add default model-provider timeout/retry settings for Pi-backed agent runs
  • classify provider failures into durable MODEL_PROVIDER_* error codes
  • attach provider errors to the active run so the UI exits thinking and displays error_code + message inline
  • preserve classified provider error codes in process-wake error rows
  • add model provider error classification tests

Verification

  • pnpm --filter @electric-ax/agents-mcp build
  • pnpm --filter @electric-ax/agents-runtime typecheck
  • pnpm --filter @electric-ax/agents-runtime exec vitest run test/model-provider-error.test.ts
  • pnpm --filter @electric-ax/agents-runtime build
  • pnpm --filter @electric-ax/agents-server-ui typecheck

@KyleAMathews KyleAMathews requested a review from thruflo June 5, 2026 18:18
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Desktop Builds

Build artifacts for commit 2285bda.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Passed Installer
Linux x64 Passed AppImage / deb

Workflow run

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.91%. Comparing base (cb6ae57) to head (2285bda).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ackages/agents-runtime/src/model-provider-error.ts 93.22% 8 Missing ⚠️
.../agents-server-ui/src/components/AgentResponse.tsx 0.00% 5 Missing ⚠️
packages/agents-runtime/src/pi-adapter.ts 95.83% 2 Missing ⚠️
packages/agents-runtime/src/context-factory.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4521      +/-   ##
==========================================
+ Coverage   54.88%   56.91%   +2.03%     
==========================================
  Files         307      355      +48     
  Lines       34522    38758    +4236     
  Branches     9871    10932    +1061     
==========================================
+ Hits        18949    22061    +3112     
- Misses      15554    16639    +1085     
- Partials       19       58      +39     
Flag Coverage Δ
packages/agents 71.62% <ø> (-0.28%) ⬇️
packages/agents-mcp 77.54% <ø> (?)
packages/agents-mobile 84.09% <ø> (ø)
packages/agents-runtime 81.42% <94.11%> (+0.44%) ⬆️
packages/agents-server 72.96% <ø> (+0.20%) ⬆️
packages/agents-server-ui 6.14% <0.00%> (+0.24%) ⬆️
packages/electric-ax 46.42% <ø> (ø)
packages/experimental 87.73% <ø> (?)
packages/react-hooks 86.48% <ø> (?)
packages/start 82.83% <ø> (?)
packages/typescript-client 91.71% <ø> (?)
packages/y-electric 56.05% <ø> (?)
typescript 56.91% <91.66%> (+2.03%) ⬆️
unit-tests 56.91% <91.66%> (+2.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KyleAMathews KyleAMathews force-pushed the fix/4520-model-provider-errors branch from 67b9ae1 to a81e435 Compare June 5, 2026 18:20
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Mobile Build

Local mobile checks ran for commit 2285bda.

The EAS Android preview build was skipped because the mobile-eas-build label is not present.
Add the mobile-eas-build label to this PR to produce an installable preview build.

Workflow run

@samwillis samwillis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one issue that looks worth fixing before merge:

The new modelTimeout in packages/agents-runtime/src/pi-adapter.ts is armed once before agent.prompt() / agent.continue() and only cleared when the whole Pi agent run settles. That promise can include tool execution and multi-step model/tool loops, so a valid run with a slow tool or several turns can be aborted after the default 30s and reported as MODEL_PROVIDER_TIMEOUT, even if the model already responded successfully.

I’d scope the fallback to actual provider stream calls, or rely on Pi’s timeoutMs passthrough if that is per-provider-request. As written, long-running tools can become false provider timeouts.

Reviewed interactively with GPT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add model provider timeouts and clearer offline/provider error feedback

2 participants